package cn.itcast.bos.interceptor;

import org.apache.struts2.ServletActionContext;
import org.springframework.jca.context.BootstrapContextAware;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;

import cn.itcast.bos.domain.User;

public class BOSLogininterceptor extends MethodFilterInterceptor {

	@Override
	protected String doIntercept(ActionInvocation invocation) throws Exception {
		//System.out.println("拦截器执行了...........");
		User user = (User) ServletActionContext.getRequest().getSession().getAttribute("user");
		if (user == null) {
			//没登录 去登录页面
			return "login";
		} else {
			//已经登录  放行
			return invocation.invoke();
		}
	}

}
